<?php
namespace Controller;

require_once("View/PageView.php");
require_once("View/LoginView.php");
	
class LoginController {
		
	public function applicationController(){	
		$loginView = new \View\LoginView();
		$pView = new \View\PageView();
		$title = $loginView->getLoginTitle();
		$HTML = $loginView->getLoginHTML();
		$loginAttempt = $loginView->loginAttemptSuccessful();
		$logoutAttempt = $loginView->logoutAttemptSuccessful();
		
		if($loginAttempt){
			$title = $loginView->getLogoutTitle();
			$HTML = $loginView->getLogoutHTML();		
		}
		else{
			$title = $loginView->getLoginTitle();
			$HTML = $loginView->getLoginHTML();
		}
		if($logoutAttempt){
			//Session_destroy för att ta bort sessionen.
			session_destroy();
			$title = $loginView->getLoginTitle();
			$HTML = $loginView->getLoginHTML();
		}
		
		echo $pView->getPage("$title", "$HTML");
	}
}